import { request } from '@/utils/request';
import { RequestEnum } from '@/enums/httpEnum';

export const popularizeApi = {
  popularizeList: '/popularize/list',
  popularizeDetail: '/popularize/detail',
  popularizeAdd: '/popularize/add',
  popularizeUpdate: '/popularize/update',
  popularizeDelete: '/popularize/delete',
  popularizeEnabled: '/popularize/enabled',
} as const;

export const createPopularize = (data: API.CreatePopularizeParams) => {
  return request({
    url: popularizeApi.popularizeAdd,
    method: RequestEnum.POST,
    data,
  });
};

export const updatePopularize = (data: API.UpdatePopularizeParams) => {
  return request({
    url: popularizeApi.popularizeUpdate,
    method: RequestEnum.PUT,
    data,
  });
};

export const deletePopularize = (params: { id: number }) => {
  return request({
    url: popularizeApi.popularizeDelete,
    method: RequestEnum.DELETE,
    params,
  });
};

export const disablePopularize = (id: number) => {
  return request({
    url: `${popularizeApi.popularizeEnabled}?id=${id}`,
    method: RequestEnum.POST,
  });
};
